package com.android.takagism.utils;


import androidx.annotation.Nullable;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Random;
import java.util.Set;

public abstract class PuzzleAbstract {
    int puzzleId;
    String type = "";
    String question = "";
    Object answer;
    int hardLevel;
    Clue clue;
    static Set<Object> errorAnswers;
    static LinkedList<Object> errorAnswersList = new LinkedList<>();

    public abstract Object check(Object answer) throws Exception;

    public static Set<Object> getErrorAnswers() {
        return errorAnswers;
    }

    public LinkedList<String> product4Errors() {
        if (errorAnswersList==null){
            throw new RuntimeException("子类必须在静态中初始化LIST");
        }
        LinkedList<String> strings = new LinkedList<>();
        Random random = new Random();
        for (int j = 0; j < 4; j++) {
            int i = random.nextInt(errorAnswersList.size());
            strings.add(errorAnswersList.get(i).toString());
        }
        return strings;
    }

    public PuzzleAbstract(@Nullable Clue clue) {
        this.clue = clue;
    }

    public Clue getClue() {
        return clue;
    }

    public void setClue(Clue clue) {
        this.clue = clue;
    }

    public int getHardLevel() {
        return hardLevel;
    }

    public void setHardLevel(int hardLevel) {
        this.hardLevel = hardLevel;
    }

    public int getPuzzleId() {
        return puzzleId;
    }

    public void setPuzzleId(int puzzleId) {
        this.puzzleId = puzzleId;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getQuestion() {
        return question;
    }

    public void setQuestion(String question) {
        this.question = question;
    }

    public Object getAnswer() {
        return answer;
    }

    public void setAnswer(Object answer) {
        this.answer = answer;
    }
}
